<!-- 项目经理确定所选择的人员-->
<template>
  <tl-sub-page :render="render" :visible.sync="visible" v-dialogDrag :title="title" :close-on-click-modal="false" class="tl-dialog" width="1200px" @open="open" @close="close">
    <el-row v-for="(item,index) in modelInfos" :key="index">
      <el-form class="tl-form" ref="dealform" :model="item" label-width="150px" :disabled="disableEditSubmit">
        <el-row>
          <el-col :span="18">
            <el-form-item label="需求说明" prop="requirementdescription" :rules="rules.rulesForCompetitorInfo">
              <el-input v-model="item.requirementdescription" type="textarea" :rows="4" maxlength="1000" show-word-limit></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6" class="approvalButton">
            <el-button icon="el-icon-s-promotion" @click="agreePerson(item)" type="success">同意</el-button>
            <el-button @click="disAgreePerson(item)" icon="el-icon-close" type="danger">回退</el-button>
          </el-col>
        </el-row>
        <el-col :span="18">
          <el-form-item label="传阅人" prop="circulatedcode" :rules="rules.rulesForInfo">
            <tl-ref-user v-model="item.circulatedcode" :initDisplayData.sync="item.circulatedname" dataType="code" :singleSelect="false">
            </tl-ref-user>
          </el-form-item>
        </el-col>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :type="disableEditSubmit === false ? 'text' : 'primary'" @click="doCancelEdit">取消</el-button>
        <el-button type="primary" @click="doSubmitEdit" :loading="saveLoading" v-if="disableEditSubmit === false">确认</el-button>
      </div>
    </el-row>
  </tl-sub-page>
</template>

<script>
/** mixins */
import { mixin_edit } from '@tapui/mixins/mixin_edit'

/** 子组件 */
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
import refListVue from '../pmIndexTabPermission/refList.vue'
/** VUE配置 */
export default {
  mixins: [mixin_edit],
  components: {},
  data() {
    return {
      moduleTitle: '项目传阅反馈',
      urlPrefix: '/mpm/projectCirculated/',
      url: {
        list: '/mpm/projectCirculated/list',
        agreePerson: '/mpm/projectCirculated/update'
      },
      render: 'el-dialog',
      modelInfos: [], // 临时请求参数
      flag: true
    }
  },
  methods: {
    open() {
      var projectCode = this.$parent.model.projectcode
      return getAction(this.url.list, { projectCode: projectCode, latestphase: "01" })
        .then((res) => {
          if (res.success) {
            if (res.result.dataList !== null && res.result.dataList.length > 0) {
              this.modelInfos = res.result.dataList
              console.log(this.modelInfos)
            }
          } else {
            this.$tap.alert(res.message, 'warning')
          }
        })
    },
    // 拼装请求参数
    getQueryParams() {
      this.$set(this.model, 'projectname', this.$parent.model.projectname)
      this.$set(this.model, 'projectcode', this.$parent.model.projectcode)
      this.$set(this.model, 'orgname', this.$parent.model.orgname)
      this.$set(this.model, 'orgcode', this.$parent.model.orgcode)
      this.$set(this.model, 'deptname', this.$parent.model.operationdeptname)
      this.$set(this.model, 'username', this.user.name)
      this.$set(this.model, 'usercode', this.user.code)
      this.$set(this.model, 'projectmanager', this.model.projectmanager)
      this.$set(this.model, 'projectmanagercode', this.model.projectmanagercode)
      this.$set(this.model, 'latestphase', '01') // 项目经理提交反馈阶段
      // 确定人要不要
      this.$set(this.model, 'state', '01') // 项目经理提交反馈阶段
      console.log(this.model)
    },
    // 项目经理同意所选人员
    agreePerson(item) {
      console.log(item)
      /* putAction(this.url.agreePerson, item)
         .then((res) => {
           if (res.success) {
             this.$tap.message(res.message, 'success')
             this.visible = false
             this.$emit('refresh')
           } else {
             this.$tap.alert(res.message, 'warning')
           }
           this.afterSubmit()
           this.saveLoading = false
         })
         .catch((err) => {
           this.saveLoading = false
         })*/
    },
    // 项目经理想修改直属领导所选的人员
    disAgreePerson(item) {
      console.log(item)
      /* putAction(this.url.agreePerson, item)
         .then((res) => {
           if (res.success) {
             this.$tap.message(res.message, 'success')
             this.visible = false
             this.$emit('refresh')
           } else {
             this.$tap.alert(res.message, 'warning')
           }
           this.afterSubmit()
           this.saveLoading = false
         })
         .catch((err) => {
           this.saveLoading = false
         })*/
    }
  }
}
</script>
<style scoped>
.approvalButton {
  padding-top: 20px;
  padding-left: 40px;
}
</style>
